<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    // var simplifyPath = function(path) {
    //     const names = path.split("/");
    //     const stack = [];
    //     for (const name of names) {
    //         if (name === "..") {
    //             if (stack.length) {
    //                 stack.pop();
    //             }
    //         } else if (name.length && name !== ".") {
    //             stack.push(name);
    //
    //         }
    //     }
    //
    //     return "/" + stack.join("/");
    // };
    let simplePath = function (path){
        let arr = path.split('/')
        console.log(arr)
        let newArr = [];
        for(let i of arr){
            if(i){
                if(i != '..' && i != '.'){
                    newArr.push(i)
                }else if( i == '..'){
                    newArr.pop()
                }
            }
        }
        return '/' + newArr.join('/')
    }
    simplePath('/name//ww/.././//qq')
</script>
</body>
</html>
